package com.rerun.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.rerun.entity.vo.ResumeTemplateParam;
import com.rerun.entity.Resume;
import com.rerun.entity.vo.ParkResumeVo;
import com.rerun.mapper.ResumeMapper;
import com.rerun.service.IResumeService;
import com.rerun.vo.park.InteviewResumeVo;
import com.rerun.vo.park.ParkResumeSearchVo;
import com.rerun.vo.park.ReceivedResumeVo;

import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * The type Resume service.
 *
 * @author dax.
 * @version v1.0
 * @since 2017 /9/29 9:28
 */
@Service
public class ResumeServiceImpl extends ServiceImpl<ResumeMapper,Resume> implements IResumeService {
    @Resource
    private ResumeMapper resumeMapper;
    @Override
    public List<Resume> selectWhoNoAccount() {
        return resumeMapper.selectWhoNoAccount();
    }

    @Override
    public Resume selectByMemberId(String memberId) {
        return resumeMapper.selectByMemberId(memberId);
    }

	@Override
	public Resume selectByPhoneNumber(String phone) {
		return resumeMapper.selectByPhoneNumber(phone);
	}
	@Override
	public Page<ParkResumeVo> selectResumeListPage(ParkResumeSearchVo resumeSearchVo, Page<ParkResumeVo> page) {
        page.setRecords(baseMapper.selectResumeListPage(page, resumeSearchVo));
        return page;
	}

	@Override
	public Resume lookResume(String memeberId) {
		return resumeMapper.resumeAllDetail(memeberId);
	}

	@Override
	public Page<ParkResumeVo> selectCollectResumesPage(Page<ParkResumeVo> page,String parkId) {
		page.setRecords(resumeMapper.selectCollectResumesPage(page,parkId));
		return page;
	}
    @Override
    public ResumeTemplateParam selectResumeDetailByMemberId(String memberId) {
        return resumeMapper.selectResumeDetailByMemberId(memberId);
    }

	@Override
	public Page<ReceivedResumeVo> receivedResume(String parkId, Page<ReceivedResumeVo> page) {
		page.setRecords(baseMapper.receivedResumeListPage(page, parkId));
        return page;
	}

	@Override
	public Page<InteviewResumeVo> forTheInterview(String status,String parkId, Page<InteviewResumeVo> page) {
		page.setRecords(baseMapper.forTheInterviewListPage(status,page, parkId));
        return page;
	}

	@Override
	public int resumeShowAndHide(String memberId, Integer status) {
		return resumeMapper.resumeShowAndHide(memberId,status);
	}

	@Override
	public void updateMemberIdTask() {
		List<String> phoneNumbers = selectPhoneNumberNoMemberId();
		if (CollectionUtils.isNotEmpty(phoneNumbers)) {
			for (String phoneNumber:phoneNumbers){
				resumeMapper.updateMemberIdTask(phoneNumber);
			}
		}
	}

	@Override
	public List<String> selectPhoneNumberNoMemberId() {
		return resumeMapper.selectPhoneNumberNoMemberId();
	}

	@Override
	public int getResumeStatusNum(String parkId, String status) {
		int num = resumeMapper.getResumeStatusNum(parkId,status);
		return num;
	}

}
